/*
 * npc_lua.h
 */

#ifndef NPC_LUA_H_
#define NPC_LUA_H_

#include <lua/luaR.h>
#include <lua/luaRcallback.h>
#include <controller/event.h>

/*
 * Initializes the NPC Lua interface.
 */
int npc_lua_initialize();

/*
 * Sets the unit creation callback.
 * This callback should create the structure housing the game-specific game
 * stats from a Lua argument list, returned as an anonymous pointer.
 * A pointer to the unit the game stats are being created for is passed to
 * encourage developers to house a pointer to the ROWGAGE unit struct so that
 * both structures contain pointers to each other.
 */
int npc_lua_stats( void * (*get_stats)(int, struct lua_arg_list*, unit*) );

/*
 * Lua hook to the function:
 * void npc_create( unsigned long x, unsigned long y, unsigned long z,
 *     unsigned int size, unsigned int hp, const char *name);
 */
void npc_lua_create( int argc, struct lua_arg_list *argv );

/*
 * Sets the unit stats callback.
 * This callback should take the given anonymous struct (which should be the
 * game-specific unit stats struct), retrieves the relevant information from it,
 * and push it onto the Lua stack to be used by the npc_lua_getInfo function.
 * Developers cannot access the Lua stack directly, and must instead use the
 * provided ROWGAGE functions.
 */
int npc_lua_push_callback( void (*stats_push)(void*) );

/*
 * Pushes the given number with the given key onto the Lua stack to be set in
 * the table returned by npc_lua_getInfo.
 */
int npc_lua_pushnumber( const char *key, double value );

/*
 * Pushes the given string with the given key onto the Lua stack to be set in
 * the table returned by npc_lua_getInfo.
 */
int npc_lua_pushstring( const char *key, const char *value );

/*
 * Calls the Lua function "npcTurn", which goes through each created monster and
 * allows it to take an action.
 */
void npc_lua_round();

#endif
